home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 04 - 1988 / 04.10 Oct 88 / TransferSources / packhead.asm < prev    next >
Encoding:
Assembly Source File  |  1988-05-22  |  2.3 KB  |  95 lines  |  [TEXT/MPS ]

  1. ;*******************************************************************
  2. ;
  3. ;    packhead.asm
  4. ;    ------------
  5. ;
  6. ;    (c) 1987, 1988 Attic Software
  7. ;
  8. ;    header and assembly routines for PACK segment of Transfer.
  9. ;
  10. ;*******************************************************************
  11.  
  12. ;*******************************************************************
  13. ;    exported routines
  14. ;*******************************************************************
  15.  
  16.     xdef        setglobal
  17.     xdef        getglobal
  18.     xdef        runiaz
  19.  
  20. ;*******************************************************************
  21. ;
  22. ;    The jump table begins with a jump into the body of the
  23. ;    table, indexed by D0 (the routine selector).  Then it
  24. ;    branches to the appropriate routine.
  25. ;
  26. ;*******************************************************************
  27.     
  28.     xref        initglobals
  29.     xref        setdir
  30.  
  31.     jmp        2(PC,D0.w)
  32.     bra.w        initglobals
  33.     bra.w        setdir
  34.  
  35. ;*******************************************************************
  36. ;
  37. ;    The global access routines provide a way to save the address
  38. ;    of the global record, which would otherwise be lost.  This
  39. ;    is done by writing the address into a four-byte constant in
  40. ;    the PACK segment.
  41. ;
  42. ;    Note:  writing to code segments is frowned upon in some
  43. ;    circles.  This objection has a legitimate basis:  self-
  44. ;    modifying code is a horror.  It makes debugging difficult,
  45. ;    and maintenance impossible.  (5 points:  where in “Inside
  46. ;    Mac” are you instructed to write self-modifying code?)  In
  47. ;    this instance, I an not modifying code; I am modifying data,
  48. ;    and there's nothing wrong with that.
  49. ;
  50. ;    procedure setglobal(value : long);
  51. ;    function getglobal : long;
  52. ;
  53. ;*******************************************************************
  54.  
  55.     module        'access'
  56.  
  57. setglobal
  58.     movea.l        (SP)+,A0
  59.     lea        dummy,A1
  60.     Move.l        (SP)+,(A1)
  61.     jmp        (A0)
  62.  
  63. getglobal
  64.     movea.l        (SP)+,A0
  65.     Move.l        dummy,(SP)
  66.     jmp        (A0)
  67.  
  68. dummy
  69.     dc.w        'xxxx'
  70.  
  71. ;*******************************************************************
  72. ;
  73. ;    procedure runiaz(iazaddr : long)
  74. ;
  75. ;    The runiaz routine zeros the “iaznotify” hook, and calls
  76. ;    the routine that preceded Transfer's routine, if any.
  77. ;
  78. ;*******************************************************************
  79.  
  80.     module        'runiaz'
  81.  
  82. runiaz
  83.     clr.l        $33C
  84.     movea.l        4(SP),A0
  85.     Move.l        (SP)+,(SP)
  86.  
  87.     cmpa.l        #0,A0
  88.     beq.w        L0001
  89.     Move.l        A0,-(SP)
  90.  
  91. L0001
  92.     rts
  93.  
  94. ;*******************************************************************
  95.